import req from '@/request/request';
import mockReq from '@/request/mock';

// 模拟数据  banner
export const getMockBanner = () => mockReq.get('/home/banner');

// 模拟数据 floor
export const getMockFloor = () => {
  return mockReq.get('/home/floor');
};

// 获取分类列表
export const getCategoryList = () => req.get('/product/getBaseCategoryList');

// 获取Search页搜索数据
export const getSearchList = (searchUrl) => req.post('/list', searchUrl);

// 获取商品详情列表
export const getDetailsList = (skuId) => req.get(`/item/${ skuId }`);

// 获取商品详情
export const getGoodDetail = skyId => req.get(`/item/${ skyId }`);

// 获取购物车列表
export const getCartList = () => req.get('/cart/cartList');

// 添加商品到购物车
export const insertCartNum = (skuId, skuNum) => req.post(
    `/cart/addToCart/${ skuId }/${ skuNum }`);

// 商品数量修改
export const updateCartNum = (skuId, skuNum) => req.post(
    `/cart/addToCart/${ skuId }/${ skuNum }`);

// 选中购物车商品
export const checkCartGood = (skuId, isChecked) => req.get(
    `/cart/checkCart/${ skuId }/${ isChecked }`);

// 批量选中购物车商品
export const checkManyCartGood = (skuIdList, isChecked) => req.post(
    `/cart/batchCheckCart/${ isChecked }`, skuIdList);

// 删除单个购物车商品
export const deleteSingleCartGood = (skuId) => req.delete(
    `/cart/deleteCart/${ skuId }`);

// 删除多个购物车商品
export const deleteManyCartGood = (skuIdList) => req.delete(
    `/cart/batchDeleteCart`, {
      data: skuIdList,
    });

// 获取验证码
export const getVerifyCode = phone => req.get(
    `user/passport/sendCode/${ phone }`);

// 用户注册
export const userRegister = userinfo => req.post(`/user/passport/register`,
    userinfo);

// 用户登录
export const userLogin = userinfo => req.post(`/user/passport/login`,
    userinfo);

// 用户退出登录
export const userLogout = () => req.get('/user/passport/logout');

// 获取用户信息
export const getUserInfo = () => req.get(`/user/passport/auth/getUserInfo`);
